/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class DeleteBabyManagerData {
	public void deleteTestData() throws PersistentException {
		PersistentTransaction t = orm.BabyManagerPersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.PacienteDAO lormPacienteDAO = lDAOFactory.getPacienteDAO();
			orm.Paciente lormPaciente = lormPacienteDAO.loadPacienteByQuery(null, null);
			// Delete the persistent object
			lormPacienteDAO.delete(lormPaciente);
			orm.dao.ProfesionalDAO lormProfesionalDAO = lDAOFactory.getProfesionalDAO();
			orm.Profesional lormProfesional = lormProfesionalDAO.loadProfesionalByQuery(null, null);
			// Delete the persistent object
			lormProfesionalDAO.delete(lormProfesional);
			orm.dao.EncuestaDAO lormEncuestaDAO = lDAOFactory.getEncuestaDAO();
			orm.Encuesta lormEncuesta = lormEncuestaDAO.loadEncuestaByQuery(null, null);
			// Delete the persistent object
			lormEncuestaDAO.delete(lormEncuesta);
			orm.dao.PreguntaDAO lormPreguntaDAO = lDAOFactory.getPreguntaDAO();
			orm.Pregunta lormPregunta = lormPreguntaDAO.loadPreguntaByQuery(null, null);
			// Delete the persistent object
			lormPreguntaDAO.delete(lormPregunta);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			DeleteBabyManagerData deleteBabyManagerData = new DeleteBabyManagerData();
			try {
				deleteBabyManagerData.deleteTestData();
			}
			finally {
				orm.BabyManagerPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
